/*
 * @Author: szx
 * @Date: 2022-02-25 12:49:13
 * @LastEditTime: 2022-02-25 12:56:13
 * @Description:
 * @FilePath: \leetcode\500-599\537\537.js
 */
/**
 * @param {string} num1
 * @param {string} num2
 * @return {string}
 */
var complexNumberMultiply = function (num1, num2) {
    const a = num1.indexOf('+');
    const b = num1.indexOf('i');
    const shi1 = Number(num1.substring(0, a));
    const xu1 = Number(num1.substring(a + 1, b));
    const c = num2.indexOf('+');
    const d = num2.indexOf('i');
    const shi2 = Number(num2.substring(0, c));
    const xu2 = Number(num2.substring(c + 1, d));
    const res_shi = shi1 * shi2 - xu1 * xu2;
    const res_xu = shi1 * xu2 + shi2 * xu1;
    return res_shi + '+' + res_xu + 'i';
};
console.log(complexNumberMultiply('1+1i', '1+1i'));
